home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CODECVT_CC
- #define __CODECVT_CC
- #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
- /***************************************************************************
- *
- * codecvt.cc - Definitions for the Standard Library code conversion facet
- *
- *
- ***************************************************************************
- *
- * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
- * ALL RIGHTS RESERVED *
- * The software and information contained herein are proprietary to, and
- * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
- * intends to preserve as trade secrets such software and information.
- * This software is furnished pursuant to a written license agreement and
- * may be used, copied, transmitted, and stored only in accordance with
- * the terms of such license and with the inclusion of the above copyright
- * notice. This software and information or any other copies thereof may
- * not be provided or otherwise made available to any other person.
- *
- * Notwithstanding any other lease or license that may pertain to, or
- * accompany the delivery of, this computer software and information, the
- * rights of the Government regarding its use, reproduction and disclosure
- * are as set forth in Section 52.227-19 of the FARS Computer
- * Software-Restricted Rights clause.
- *
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 252.227-7013.
- * Contractor/Manufacturer is Rogue Wave Software, Inc.,
- * P.O. Box 2328, Corvallis, Oregon 97339.
- *
- * This computer software and information is distributed with "restricted
- * rights." Use, duplication or disclosure is subject to restrictions as
- * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
- * Computer Software-Restricted Rights (April 1985)." If the Clause at
- * 18-52.227-74 "Rights in Data General" is specified in the contract,
- * then the "Alternate III" clause applies.
- *
- **************************************************************************/
-
- #ifndef _RWSTD_NO_NAMESPACE
- namespace std {
- #endif
-
- // -------------------------------------------------
- // Facet codecvt<internT,externT,stateT> member templates.
- // -------------------------------------------------
-
- #ifndef _MSC_VER
- template <class internT,class externT,class stateT>
- locale::id codecvt<internT,externT,stateT>::id;
-
- template <class internT,class externT,class stateT>
- codecvt<internT,externT,stateT>::~codecvt() {}
-
- template <class internT, class externT, class stateT>
- codecvt_base::result
- codecvt<internT,externT,stateT>::do_out (stateT&,
- const internT* from, const internT* from_end, const internT*& from_next
- , externT* to, externT* to_end, externT*& to_next) const
- {
- return noconv;
- }
-
- template <class internT, class externT, class stateT>
- codecvt_base::result
- codecvt<internT,externT,stateT>::do_in (stateT&,
- const externT* from, const externT* from_end, const externT*& from_next
- , internT* to, internT* to_end, internT*& to_next) const
- {
- return noconv;
- }
-
- template <class internT,class externT,class stateT>
- bool codecvt<internT,externT,stateT>::do_always_noconv ()
- const _RWSTD_THROW_SPEC_NULL
- {
- return true;
- }
-
- template <class internT,class externT,class stateT>
- int codecvt<internT,externT,stateT>::do_encoding()
- const _RWSTD_THROW_SPEC_NULL
- {
- return sizeof(internT) == sizeof(externT);
- }
-
- template <class internT,class externT,class stateT>
- int codecvt<internT,externT,stateT>::do_length
- (const stateT&, const internT *from, const internT *from_end, size_t max)
- const
- {
- return min (size_t(from_end-from), max);
- }
-
- template <class internT,class externT,class stateT>
- int codecvt<internT,externT,stateT>::do_max_length ()
- const _RWSTD_THROW_SPEC_NULL
- {
- return 1;
- }
-
- template <class internT,class externT,class stateT>
- _TYPENAME codecvt<internT,externT,stateT>::internal_string_type
- codecvt<internT,externT,stateT>::in (const external_string_type &s) const
- {
- // Calculate the number of internT's that will be produced. (I'm not sure
- // what to use for max in the do_length call; too bad char_traits can't tell
- // me.) (This needs to be revised to use separate in and out versions of
- // do_length once someone comes up with the right syntax.)
- int n=1000; // do_length(stateT(0),s.c_str(),s.c_str()+s.length(),
- // numeric_limits<size_t>::max() / do_max_length());
-
- const externT *unused_from;
- internT *unused_to;
-
- internT *conversion_buffer=new internT[n];
- stateT stt(0);
- n=do_in(stt,s.c_str(),s.c_str()+s.length(),unused_from,
- conversion_buffer,conversion_buffer+n,unused_to);
- internal_string_type result(conversion_buffer,conversion_buffer+n);
- delete[] conversion_buffer;
- return result;
- }
-
- #endif // _MSC_VER
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- #endif
-
- #endif /* __CODECVT_CC */
- #pragma option pop
-